<?php

/**
 * Collection form base class.
 *
 * @method Collection getObject() Returns the current form's model object
 *
 * @package    Serag
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCollectionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'customer_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Customer'), 'add_empty' => true)),
      'user_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'pay_type'      => new sfWidgetFormChoice(array('choices' => array('cash' => 'cash', 'cheque' => 'cheque', 'transfer' => 'transfer'))),
      'due_date'      => new sfWidgetFormDateTime(),
      'amount'        => new sfWidgetFormInputText(),
      'created_at'    => new sfWidgetFormDateTime(),
      'cheque_number' => new sfWidgetFormInputText(),
      'bank_name'     => new sfWidgetFormInputText(),
      'line_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Line'), 'add_empty' => false)),
      'date'          => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'customer_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Customer'), 'required' => false)),
      'user_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'required' => false)),
      'pay_type'      => new sfValidatorChoice(array('choices' => array(0 => 'cash', 1 => 'cheque', 2 => 'transfer'), 'required' => false)),
      'due_date'      => new sfValidatorDateTime(array('required' => false)),
      'amount'        => new sfValidatorNumber(array('required' => false)),
      'created_at'    => new sfValidatorDateTime(array('required' => false)),
      'cheque_number' => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'bank_name'     => new sfValidatorString(array('max_length' => 50)),
      'line_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Line'))),
      'date'          => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('collection[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Collection';
  }

}
